package top.leix.springdemo.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import top.leix.springdemo.Res;
import top.leix.springdemo.pojo.*;
import top.leix.springdemo.services.ApplyLabTeacherService;
import top.leix.springdemo.services.ApplyRepairTeacherService;

import javax.annotation.Resource;

@Slf4j
@Tag(name = "教师接口")
@CrossOrigin
@RestController
@RequestMapping("/teacher")
public class TeacherController {
    @Resource
    ApplyLabTeacherService applyLabTeacherService;
    @Resource
    ApplyRepairTeacherService applyRepairTeacherService;
    /**
     * 添加申请的表单
     * @param applyLabTeacher
     * @return
     */
    @PostMapping("/apply")
    public Res addApplication(@RequestBody ApplyLabTeacher applyLabTeacher) {
        return applyLabTeacherService.addApplication(applyLabTeacher);
    }

    /**
     * 更新
     * @param applyLabTeacher
     * @return
     */
    @PostMapping("/update")
    public Res updateApplication(@RequestBody ApplyLabTeacher applyLabTeacher) {
        return applyLabTeacherService.updateApplication(applyLabTeacher);
    }
    /**
     * 修改维修申请,只有在status是Pending才能改
     * @param applyRepairTeacher
     * @return
     */
    @PostMapping("updateRepairApplication")
    public Res updateRepairApplication(@RequestBody ApplyRepairTeacher applyRepairTeacher) {
        return applyRepairTeacherService.updateRepairApplication(applyRepairTeacher);
    }
    /**
     * 根据账号，查询当前教师未审核
     */
    @PostMapping("queryPending")
    public Res queryPending(@RequestBody String userAccount) {
        return applyLabTeacherService.queryPending(userAccount);
    }
    /**
     * 根据账号，查询当前学生已通过
     */
    @PostMapping("queryScheduled")
    public Res queryOK(@RequestBody String userAccount) {
        return applyLabTeacherService.queryScheduled(userAccount);
    }

    /**
     * 查询当前学生的所有表单
     */
    @PostMapping("queryHistory")
    public Res queryHistory(@RequestBody String userAccount) {
        return applyLabTeacherService.queryHistory(userAccount);
    }

    /**
     * 老师申请维修
     * @param applyRepairTeacher
     * @return
     */
    @PostMapping("addRepair")
    public Res addRepair(@RequestBody ApplyRepairTeacher applyRepairTeacher) {
        return applyRepairTeacherService.addRepair(applyRepairTeacher);
    }



    /**
     * 根据账户查询提交的维修申请
     * @param userAccount
     * @return
     */
    @PostMapping("queryRepairApplication")
    public Res queryRepairApplication(@RequestBody String userAccount) {
        return applyRepairTeacherService.queryRepairApplication(userAccount);
    }

    /**
     * 维修状态查询
     * @param userAccount
     * @return
     */
    @PostMapping("queryRepairPending")
    public Res queryRepairPending(@RequestBody String userAccount) {
        return applyRepairTeacherService.queryRepairPending(userAccount);
    }
    @PostMapping("queryRepairRepairing")
    public Res queryRepairRepairing(@RequestBody String userAccount) {
        return applyRepairTeacherService.queryRepairRepairing(userAccount);
    }
    @PostMapping("queryRepairFinished")
    public Res queryRepairFinished(@RequestBody String userAccount) {
        return applyRepairTeacherService.queryRepairFinished(userAccount);
    }
}
